import 'package:qr_code_app/common/service/app_data.dart';
import 'package:todo_flutter/todo_flutter.dart';

class ApiService {
  static const String shareUrl = 'https://share.jiazhuan.com.cn/';

  ///根据当前项目环境获取请求地址
  static ApiInfo get currentByEnv {
    final String proxyIp = AppData.getProxyIp();
    final bool proxy = AppData.getProxy();
    if (Env.isDev) {
      return ApiInfo(
        url: 'https://api.jiazhuan.com.cn/',
        proxyIp: proxyIp,
        proxy: proxy,
      );
    } else if (Env.isTest) {
      return ApiInfo(
        url: 'https://api.jiazhuan.com.cn/',
        proxyIp: proxyIp,
        proxy: proxy,
      );
    } else if (Env.isPre) {
      return ApiInfo(
        url: 'https://api.jiazhuan.com.cn/',
        proxyIp: proxyIp,
        proxy: proxy,
      );
    }
    return ApiInfo(
      url: 'http://127.0.0.1/:5000/',
      proxyIp: proxyIp,
      proxy: proxy,
    );
  }
}

class ApiInfo {
  String url;
  String proxyIp;
  int proxyPort;
  bool proxy;

  ApiInfo({
    required this.url,
    this.proxyIp = '',
    this.proxyPort = 8888,
    this.proxy = false,
  });
}
